package cn.school.ctrl;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
public class HelloController {

    @RequestMapping("/sayHello")
    public String sayHello(HttpServletRequest req) {
        req.setAttribute("msg", "打扎好,我是spring");
        return "welcome.jsp";
    }

    @RequestMapping("/sayhi")
    public ModelAndView sayHello2() {
        ModelAndView mv = new ModelAndView();
        mv.addObject("msg", "welcome to spring mvc");
        mv.setViewName("welcome.jsp");
        return mv;
    }
}
